`
https://leetcode.cn/problems/trim-a-binary-search-tree/
`

/**
 * Definition for a binary tree node.
 * function TreeNode(val, left, right) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.left = (left===undefined ? null : left)
 *     this.right = (right===undefined ? null : right)
 * }
 */
/**
 * @param {TreeNode} root
 * @param {number} low
 * @param {number} high
 * @return {TreeNode}
 */
var trimBST = function (root, low, high) {
  if (root === null) return null

  // 如果 root.val 小于 low，直接返回右子树
  if (root.val < low) return trimBST(root.right, low, high)

  // 如果 root.val 大于 low，直接返回左子树
  if (root.val > high) return trimBST(root.left, low, high)

  // 否则什么都不做
  root.left = trimBST(root.left, low, high)
  root.right = trimBST(root.right, low, high)

  return root
};